#!/usr/bin/env ruby

require 'prawn'
require 'open-uri'

include Prawn::Measurements

pdf = Prawn::Document.new page_size: [mm2pt(52), mm2pt(80)]
#p pdf.bounds.height
#p pdf.bounds.width
w = pdf.bounds.width
h = pdf.bounds.height
pdf.font 'PTF55F.ttf'
#pdf.stroke {
#  pdf.polygon [-20,175], [w + 20, 175], [w + 20, 115], [-20, 115]
#}
pdf.bounding_box([-20,175], width: (w + 40), height: 60) do
  pdf.text 'Mikhail Kuryshev', size: 20, align: :center
end
#pdf.stroke {
#  pdf.polygon [w/2-40,100], [w/2 + 40, 100], [w/2 + 40, 20], [w/2-40, 20]
#}
qr = open 'http://localhost:5000/qr_hi/aHR0cHM6Ly9wbHVzLmdvb2dsZS5jb20vMTA0NjMyMTQ2MjAwNzczODUwODMy'
pdf.image qr, at: [w/2-40, 100], width: 80
puts pdf.render
